﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;

namespace NLite.Data.Schema
{
    //public class Database
    //{
    //    public readonly IEnumerable<ProcedureSchema> Procedures;
    //    public readonly IEnumerable<TableSchema> Tables;
    //    public readonly IEnumerable<TableSchema> Views;

    //    public Database(IEnumerable<ProcedureSchema> procedures, IEnumerable<TableSchema> views, IEnumerable<TableSchema> views)
    //    {
    //        Procedures = procedures == null ? new ProcedureSchema[0] : procedures;
    //        Tables = views == null ? new TableSchema[0] : views;
    //        Views = views == null ? new TableSchema[0] : views;
    //    }
    //}

    //public class TableSchema
    //{
    //    public readonly bool IsView;
    //    public readonly ColumnSchema Key;
    //    public readonly string Name;
    //    public readonly string Owner;
    //    public readonly string FullName;

    //    public TableSchema(bool isView, ColumnSchema key, string name, string owner)
    //    {
    //        IsView = isView;
    //        Key = key;
    //        Name = name;
    //        Owner = owner;
    //        FullName = string.IsNullOrEmpty(owner) ? Name : owner + "." + name;
    //        Columns = new HashSet<ColumnSchema>();
    //        Relations = new HashSet<RelationSchema>();
    //    }

    //    public ICollection<ColumnSchema> Columns { get; private set; }
    //    public ICollection<RelationSchema> Relations { get; private set; }
    //}

    //public class ProcedureSchema
    //{
    //    public readonly string FullName;
    //    public readonly string Name;
    //    public readonly string Owner;

    //    public ProcedureSchema(string name, string owner)
    //    {
    //        Name = name;
    //        Owner = owner;
    //        FullName = string.IsNullOrEmpty(owner) ? Name : owner + "." + name;
    //        InnerList = new HashSet<ParameterSchema>();
    //    }

    //    public ICollection<ParameterSchema> InnerList { get; private set; }
    //}

    //public class ColumnSchema
    //{
    //    public string ColumnType;
    //    public string Comment;
    //    public DbType DbType;
    //    public string DefaultValue;
    //    public bool IsCheck;
    //    public bool IsComputeColumn;
    //    public bool IsFK;
    //    public bool IsIdentity;
    //    public bool IsNullable;
    //    public bool IsPK;
    //    public bool IsUnique;
    //    public int Length;
    //    public string Name;
    //    public short Order;
    //    public int Precision;
    //    public int Scale;
    //    public string SqlDefualtValue;
    //    public string SystemType;
    //    public bool IsUserType
    //    {
    //        get
    //        {
    //            return ((this.SystemType == null) || (this.ColumnType.ToLower().Trim() != this.SystemType.ToLower().Trim()));
    //        }
    //    }
    //}

    //public class ParameterSchema
    //{
    //    public DbType DbType;
    //    public ParameterDirection Direction;
    //    public bool IsNullable;
    //    public string Name;
    //    public string NativeType;
    //    public int Precision;
    //    public int Scale;
    //    public int Size;
    //}

    //public class RelationSchema
    //{
    //    public readonly string ForeignKeyColumn;
    //    public readonly string ForeignKeyTable;
    //    public readonly string PrimaryKeyColumn;
    //    public readonly string PrimaryKeyTable;

    //    public override string ToString()
    //    {
    //        return string.Format("{0}.{1} = {2}.{3}", new object[] { this.ForeignKeyTable, this.ForeignKeyColumn, this.PrimaryKeyTable, this.PrimaryKeyColumn });
    //    }
    //}

    //public class PrimaryKeySchema
    //{
    //    public readonly string Name;
    //    public readonly TableSchema Table;

    //    public PrimaryKeySchema(TableSchema table, string name)
    //    {
    //        this.Columns = new HashSet<ColumnSchema>();
    //        this.Table = table;
    //        this.Name = name;
    //    }

    //    public ICollection<ColumnSchema> Columns { get; private set; }


    //}
}
